<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//猜数字
//console.log(parseInt(Math.random() * (n + 1 - m)) + m);  // [m, n]  [15, 50]
while (true){
    var num = parseInt(Math.random() * 101);  // [0, 100]
    while (true){
        var guess = parseInt(prompt("请猜一个0-100的整数:"));
        if (guess == num){
            alert("恭喜你猜对了!")
            break;
        }else if (guess < num){
            alert("遗憾, 你猜小了!")
        }else{
            alert("遗憾,你猜大了!")
        }
    }
    var again = confirm("是否再玩一局, 点确定再来一局, 点取消就回去睡觉");
    if (!again){
        break;
    }
}
</script>
</body>
</html>